package cn.swh.guguanjia.mapper;

import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * @Author: swh
 * @Description:
 * @Date: 2020/11/7 9:35
 * @Version: 1.0
 */
public class SysResourceProvider {

    public String selectPage(Map<String, Object> map) {
        return new SQL() {{
            SELECT("*");
            FROM("sys_resource ");
            WHERE("del_flag = 0 ");
            if (map.containsKey("sid") && !StringUtils.isEmpty(map.get("sid"))) {
                WHERE("parent_ids LIKE CONCAT('%',#{sid},'%') OR id=#{sid}");
            }else if (map.containsKey("name") && !StringUtils.isEmpty(map.get("name"))) {
                WHERE(" name LIKE CONCAT( '%', #{name}, '%' )");
            }

        }}.toString();
    }
}
